#!c:\Program Files\Python39\python.exe # -*- coding: UTF-8 -*- ''' $RCSfile: main.py,v $ $Revision$ $Author: markus $ $Date$ The BioCASE querytool ''' import os # ***** include the biocase.lib directory in the python sys path for importing ***** exec(open(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir, 'lib', 'biocase', 'adjustpath.py'))).read()) # exec(compile(open( os.path.abspath( os.path.join( os.path.dirname( __file__ ), os.pardir, os.pardir, 'lib', 'biocase', 'appinit.py' ) ), "rb").read(), os.path.abspath( os.path.join( os.path.dirname( __file__ ), os.pardir, os.pardir, 'lib', 'biocase', 'appinit.py' ) ), 'exec')) # import pydevd; pydevd.settrace(); from biocase.tools.templating import PageMacro from biocase.datasources import getDsaList from biocase.tools.htmltools import getDropDownHtml, getDropDownOptionHtml from biocase.querytool.general import dsa, skinDir, wrapper_url, schemaObj, schema, prefs, printOverHTTP import logging log = logging.getLogger("querytool.main") # display global DSA select box? if dsa is None: # use the datasource.html template to select a datasource first tmpl = PageMacro('Content', PageMacro.DELMODE) tmpl.load('Content', os.path.join(skinDir, 'datasource.html')) # get list of available dsa's ds_list = [dsa.name for dsa in getDsaList()] log.info("DSA list from datasource directory: %s" % ds_list) tmpl['datasource_options'] = getDropDownOptionHtml(['--select--'] + ds_list, '--select--') if wrapper_url is not None: tmpl['wrapper_url'] = wrapper_url else: # generate the search form for this dsa. use the form.html template tmpl = PageMacro('Content', PageMacro.DELMODE) tmpl.load('Content', os.path.join(skinDir, 'form.html')) tmpl['wrapper_url'] = wrapper_url tmpl['dsa'] = dsa # get the relevant form fields from preferences concepts = [] if schemaObj is not None: log.info("Use schema %s to build the form." % schema) schema = schemaObj.NS for conObj in schemaObj.concepts: conDict = {'label_display': conObj.label.replace('_', ' '), 'label': conObj.label} if not conObj.cops == '~': optionHtml = getDropDownHtml('cop%s' % conObj.label, [c for c in conObj.cops]) else: optionHtml = '' conDict['copOptions'] = optionHtml concepts.append(conDict) # create grouping drop down valDict = {} for c in schemaObj.concepts: valDict[c.label.replace('_', ' ')] = c.label tmpl['groupby_options'] = getDropDownOptionHtml(vals=valDict, default=schemaObj.grouping.label) else: log.info("Cant find preferences for the selected schema %s." % schema) tmpl.expand('Content', 'conceptlist', concepts) # create alternative schema selection tmpl['schema'] = schema tmpl['schema_options'] = getDropDownOptionHtml(vals=dict([('', '')] + [(s.label, s.NS) for s in prefs.schemas if s.NS != schema and s.hasConcepts()])) # # print HTML ! # printOverHTTP(tmpl)